import request from '@/utils/request'

// 根据员工名称查询维修预约
export const queryByEmpNameApi = (empName) => request.get(`/appointments/repair/by-emp-name?empName=${empName}`)

// 分页查询故障预约
export const queryPageApi = (userName, plateNumber, status, beginDate, endDate, page, pageSize) => 
  request.get(`/appointments/repair?userName=${userName}&plateNumber=${plateNumber}&status=${status}&beginDate=${beginDate}&endDate=${endDate}&page=${page}&pageSize=${pageSize}`)

// 更新故障预约状态
export const updateStatusApi = (data) => request.put('/appointments/repair/status', data)

// 批量删除故障预约
export const deleteBatchApi = (ids) => request.delete(`/appointments/repair?ids=${ids}`)

// 获取故障预约详情
export const queryInfoApi = (id) => request.get(`/appointments/repair/${id}`)

// 查询所有故障预约（用于导出等）
export const listApi = (userName, plateNumber, status, beginDate, endDate) => 
  request.get(`/appointments/repair/list?userName=${userName}&plateNumber=${plateNumber}&status=${status}&beginDate=${beginDate}&endDate=${endDate}`)

// 根据用户ID查询故障预约
// 用于用户端查询自己的故障预约记录
export const queryByUserIdApi = (userId) => request.get(`/appointments/repair/user?userId=${userId}`)

//根据用户ID统计故障预约数量
export const countByUserIdApi = (userId) => request.get(`/appointments/repair/user/count?userId=${userId}`)

// 获取空闲维修员列表
export const getRepairStaffApi = () => request.get('/appointments/repair/repair-staff')